<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::group(['namespace' => 'Backend', 'domain' => 'backend.blog.app'], function () {

    // 登录
    Route::get('login', 'AuthController@showLoginForm')->name('login.form.show');
    Route::post('login', 'AuthController@login')->name('login');

    Route::group(['middleware' => ['auth.backend']], function () {

        // 注销登录
        Route::post('logout', 'AuthController@logout')->name('logout');

        // 文章管理
        Route::resource('posts', 'PostsController');

        // 标签管理
        Route::resource('tags', 'TagsController');

        // 个人信息管理
        Route::get('users/{user}/edit', 'UsersController@edit')->middleware('me.to.id')->name('users.edit');
        Route::put('users/{user}/update', 'UsersController@update')->name('users.update');
    });
});

Route::group(['namespace' => 'Blog'], function () {

    // 首页
    Route::get('/', 'BlogController@index')->name('index');

    // 标签页面
    Route::get('tags/{active_tag?}', 'BlogController@tags')->name('tags');

    // 归档页面
    Route::get('archives', 'BlogController@archives')->name('archives');

    // 文章详情页面
    Route::get('posts/{slug}', 'BlogController@detail')->name('detail');
});
